import IState from "@/types/IState";
import {ActionContext} from 'vuex'
export default{
    namespaced:true,
    state(){
        return{
            num:0
        }
    },
    mutations:{
        increment(state:IState,payload:number){
            state.num+=payload
        }
    },
    actions:{
        incrementAsync(context:ActionContext<IState,any>,payload:number){
            //使用setTimeout来完成异步操作
            setTimeout(() => {
                context.commit('increment',payload)
            }, 2000);
        }
    }
}